home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #27 (Dec 87) / fortran dialogs / xfilt.asm < prev    next >
Assembly Source File  |  1987-08-25  |  1KB  |  57 lines

  1.     XDEF xfilt
  2.  
  3.     INCLUDE MacTraps.D
  4.     INCLUDE SysEqu.D
  5.     INCLUDE ToolEqu.D
  6.     INCLUDE QuickEqu.D
  7.  
  8. ;  Xfilt is the initialization code. It stores the address of the
  9. ;  FORTRAN subroutine returned from ctlprc and returns a proc pointer
  10. ;  whch can be passed to ModalDialog.
  11.  
  12. xfilt:
  13.     MOVEM.L    A0-A1,-(SP)    ;Save registers
  14.     MOVE.L    16(SP),A0    ;calling FORTRAN passes ptr to filter     LEA        service,A1    ;subroutine
  15.     MOVE.L    (A0),(A1)    ;which we store locally 
  16.     
  17.     LEA        action,A0    ;glue procedure address is returned
  18.     MOVE.L    12(SP),A1    ;to FORTRAN on the stack
  19.     MOVE.L    A0,(A1)
  20.  
  21.     MOVEM.L    (SP)+,A0-A1    ;Registers restored
  22.     RTS
  23.  
  24. ;  Action is the proc which gets called by ModalDialog. It massages the
  25. ;  stack after FORTRAN finishes with it so that a Boolean result can be
  26. ;  returned to ModalDialog.
  27.  
  28. action:
  29.     MOVEM.L    A1/D0,-(SP)        ;Save registers
  30.     PEA        result        ;Pass FORTRAN an address to store
  31.                         ;the BOOLEAN result
  32.  
  33. ;  Clone the stack
  34.     MOVE.L    24(SP),-(SP)    ;Dg_ptr
  35.     MOVE.L    24(SP),-(SP)    ;Event record
  36.     MOVE.L    24(SP),-(SP)    ;ItemHit
  37.  
  38.     MOVE.L    service,A1        ;load pointer to FORTRAN routine
  39.     JSR        (A1)            ;and call it
  40.  
  41.     MOVE.W    result,24(SP)    ;get function result and place on                         ;stack where ModalDialog expects it
  42.     MOVEM.L    (SP)+,A1/D0        ;restore registers
  43.  
  44. ;  Fix the stack so that we can RTS
  45.     MOVE.L    (SP)+,8(SP)        ;move return address
  46.     ADD.L        #8,SP            ;fix stack pointer
  47.     RTS
  48.  
  49. ;  Declare some local storage (Note that this makes
  50. ;  the routine non-reentrant)
  51.  
  52. service    DC.L    0
  53. result    DC.W    0
  54.  
  55.     end
  56.  
  57.